import {TBizcEneryEquipApi} from '@/api/equip/tBizcEneryEquipApi.js'

export const FormEvent = {
  form: {
    id: "",//主键
    taskName: "",//任务名称
    taskNo: "",//任务编码
    warehouseNo: "",//盘点对象编码
    warehouseName: "",//盘点对象名称
    stockType: "",//盘点对象类型编码
    stockTypeName: "",//盘点对象类型名称
    deptNo: "",//单位编码
    deptName: "",//单位名称
    taskTypeNo: "",//任务类型编码
    taskTypeName: "",//任务类型名称
    period: "",//周期
    periodEtime: "",//周期截止时间
    planStime: "",//计划开始时间
    planEtime: "",//计划结束时间
    personNo: "",//盘点人员编码
    personName: "",//盘点人员名称
    description: "",//详细描述
    remark: "",
    creator: "",//创建人
    createTime: "",//创建时间
    rwName: "",//任务名称
    sendPerson: "",//派单人
    sendTel: "",//派单人电话
    sendTime: "",//派单时间
  },
  rules: {},
  type: '', ////insert-update//
  initFormData(formData) { 		//初始化表单信�?//
    FormEvent.type = formData.type;
    if (FormEvent.type == 'insert') {
      for (let key in FormEvent.form) {
        FormEvent.form[key] = undefined;
      }
    } else {
      for (let key in FormEvent.form) {
        FormEvent.form[key] = formData.data[key];
      }
      this.FormEvent.form.sendTime = moment().format('YYYY-MM-DD HH:mm:ss')
    }
  },
  saveFormData() {
    if (FormEvent.type == 'insert') {
      //执行新增操作//
      const insertData = [FormEvent.form];
      return TBizcEneryEquipApi.insert(insertData);
    } else {
      //执行更新操作//
      const updateData = [FormEvent.form];
      return TBizcEneryEquipApi.update(updateData);
    }
  },

}


